@model PricePartSettingsViewModel

<fieldset class="mb-3" asp-validation-class-for="PricePartSettings">
    <label asp-for="CurrencySelectionMode">@T["Currency selection mode"]</label>

    <div class="input-group">
        <div class="input-group-append">
            <select asp-for="CurrencySelectionMode"
                    class="form-select"
                    asp-items="@(new SelectList(Model.CurrencySelectionModes, "Text", "Value"))"></select>
        </div>
    </div>

    <span class="hint">@T["Specifies the currency configuration for this PricePart."]</span>

    <fieldset class="input-group" id="@Html.IdFor(model => model.SpecificCurrencyIsoCode)-Group">
        <div class="input-group">
            <div class="input-group-append">
                <select asp-for="SpecificCurrencyIsoCode"
                        class="form-select"
                        asp-items="@(new SelectList(Model.Currencies, "Text", "Value"))"></select>
            </div>
        </div>

        <span class="hint">@T["Currency used for specific currency selection mode."]</span>
    </fieldset>
</fieldset>

<script at="Foot" depends-on="jQuery">
    jQuery(function ($) {
        $(document).ready(function () {
            SpecificCurrencyGroupVisibility(
                $('#@Html.IdFor(model => model.CurrencySelectionMode)'),
                $('#@Html.IdFor(model => model.SpecificCurrencyIsoCode)-Group'));
        });

        $('#@Html.IdFor(model => model.CurrencySelectionMode)').change(function () {
            SpecificCurrencyGroupVisibility($(this), $('#@Html.IdFor(model => model.SpecificCurrencyIsoCode)-Group'));
        });

        function SpecificCurrencyGroupVisibility($element, $group) {
            $group.toggle('@Html.ValueFor(model => model.SingleSelectionModeEditor)' === $element.val());
        }
    });
</script>
